let clientId = $('#HiddenClientId').val(); let portalName = $('#HiddenPortalName').val(); let currencyCode = $('#HiddenCurrencyCode').val(); let fractionDigit = $('#HiddenFractionDigit').val(); let gameName = $('#HiddenGameName').val(); let hasPromotions = false; let loaded = false; let promotionsType = 'BetAndWinSummaryApi'; let promotionsList = []; let gameCategory = $('#HiddenCategory').val(); let promotionMainUrl = $('#HiddenPromotionUrl').val(); let hasPersonalOfferPromotion = false let reskinName = $('#HiddenReskinName').val(); let promotionName = null; promotionsList['BetAndWinSummary'] = { 'api': 'BetAndWinSummaryApi', 'rules': 'promotion.popup.rules.text' }; promotionsList['GLOBALBETANDWINSUMMARY'] = { 'api': 'GlobalBetAndWinSummaryApi', 'rules': 'GlobalBetAndWinSummary.promotion.popup.rules.text' }; promotionsList['CASHBACK'] = { 'api': 'CashbackApi', 'rules': 'GlobalBetAndWinSummary.promotion.popup.rules.text' }; function timerItem(number) { number += ''; let a = number.split(''); if (a.length === 0) { a.push(0); a.push(0); } else if (a.length === 1) { a.unshift(0) } let html = ``; for (let i = 0; i < a.length; i++) html += `${a[i]}`; return html; } function getPromotionUrl(portalName, gameName, currencyCode) { return `${promotionMainUrl}api/com/CommonApi/GetPromotions/${portalName}/${gameName}/${currencyCode}`; } function getPromotionListUrl(clientId, portalName, currencyCode) { return `${promotionMainUrl}api/${promotionsType}/GetPromotionList/${clientId}/${portalName}/${currencyCode}`; } let ajaxReq = null; let newPromotionsArray = ['XPLUSY','DAILYLEADERBOARD','WHEEL','PRIZEDROPWHEEL','PRIZEDROPWHEELVIP','RANDOMPOINTSWHEEL','RANDOMPOINTSWHEELBANNER','LUCKYCOIN'] function getPromotions() { let promotionsUrl = getPromotionUrl(portalName, gameName, currencyCode); ajaxReq = $.get(promotionsUrl, function (data) { if (data.length > 0) { if (promotionsList[data[0]] !== undefined) { promotionsType = promotionsList[data[0]].api; $('.promotion .list.rules .captionKey').data('caption', promotionsList[data[0]].rules); } for( let index = 0; index < data.length; index++){ if ( newPromotionsArray.includes(data[index])) { loadJsFile(data[index]); promotionName = data[index]; }else if (data[index] === 'PERSONALOFFER'){ hasPersonalOfferPromotion = true; }else{ hasPromotions = true; showPromotionButton(); } } } }).fail(function (jqXHR, textStatus, errorThrown) { }); } var loadedFiles = {}; var promoFileNames = { XPLUSY: "XplusY", DAILYLEADERBOARD: "DailyLeaderBoard", PRIZEDROPWHEEL: "PrizeDropWheel", PRIZEDROPWHEELVIP: "PrizeDropWheel", WHEEL: "Wheel", RANDOMPOINTSWHEEL : "RandomPointsWheel", RANDOMPOINTSWHEELBANNER : "RandomPointsWheel", LUCKYCOIN : "LuckyCoin" } let staticContentUrl = $('#StaticContentUrl').val(); function loadJsFile(name) { if (!loadedFiles[name]) { let script = document.createElement('script'); let staticContentUrls = staticContentUrl.split('/'); staticContentUrl = ''; for (let i = 0; i < staticContentUrls.length - 1; i++) { staticContentUrl += `${staticContentUrls[i]}/`; } script.src = `${staticContentUrl === '' ? './Content/Scripts/' : staticContentUrl}Promotions/${promoFileNames[name]}.js`; document.body.appendChild(script); loadedFiles[name] = true; } else { showPromotion(name); } } function showPromotion(name) { let promos = { DAILYLEADERBOARD: "showDailyLeaderBoardPromotionButton", XPLUSY:"showXplusYpromotionButton", WHEEL: "showWheelPromotionButton", PRIZEDROPWHEEL: "showPrizeDropPromotion", PRIZEDROPWHEELVIP : "showPrizeDropPromotion", RANDOMPOINTSWHEEL : 'showRandomPointsPromotion', RANDOMPOINTSWHEELBANNER : 'showRandomPointsPromotion', LUCKYCOIN : 'showLuckyCoinPromotion' } window[promos[name]](); } function showPromotionButton() { if (hasPromotions && loaded) { //$('.promotion-icon').css('display', 'block'); $('#game-frame')[0].contentWindow.postMessage({ name: "promotion-icon-show" }, "*"); } } function promotionClientName(name) { if (name === '') return ''; name = name.split(''); return name[0] + '*****' + name.slice(-1); } function getPromotion() { let promotionsUrl = getPromotionListUrl(clientId, portalName, currencyCode); ajaxReq = $.get(promotionsUrl, function (data) { $('.captionKey').each(function (e) { let attr = GetCaption($(this).data('caption')); $(this).html(attr); }); timer(data.EndDate); let html = ``; if (data.PromotionName === 'CASHBACK') { timerJetX(data.EndDate); $('.jetx-promotion').fadeIn(100).addClass(localeCode); $('#game-container-div').hide(); DrawJetXPromotionPopup(data); return; } for (let i = 0; i < data.BetAndWinResultDetails.length; i++) { let result = data.BetAndWinResultDetails[i]; if (result.ClientId === clientId) { $('.promotion .current.top-wins .list').html(`
${result.Ranking}
${result.Score === 0 ? ' ' : result.Score}
${result.WinningValue} ${result.CurrencyCode} 
`); } if (result.PromotionWinningId !== null) { html += `
${result.Ranking}
${promotionClientName(result.DisplayName)}
${result.Score === 0 ? ' ' : result.Score}
${result.WinningValue} ${result.CurrencyCode}
`; } } $('.promotion .content .top-wins.list').html(html); $('.promotion').fadeIn(100).addClass(localeCode); }).fail(function (jqXHR, textStatus, errorThrown) { }); } function getPromotionGameUrl(category, hiddenGameType, hiddenGameName , clientId , hiddenCurrencyCode , language , returnUrl) { return `${promotionMainUrl}/menuapi/Menu/GetRedirectUrl/${category}/${hiddenGameType}/${hiddenGameName}/${clientId}/${hiddenCurrencyCode}/${language}?returnUrl=${returnUrl}`; } function openPromotionGame(game, category) { let hiddenCurrencyCode = $("#HiddenCurrencyCode").val(); let hiddenGameName = game; let hiddenGameType = game; let mobileString = bowser.mobile ? "Mobile" : ""; if (category == "Slots" || category == "Slots" + mobileString) { hiddenGameType = 'Slot'; } let clientId = $("#HiddenClientId").val(); let language = $("#HiddenLanguageParameter").val(); let returnUrl = encodeURIComponent($("#HiddenReturnUrl").val()); let promotionGameUrl = getPromotionGameUrl(category,hiddenGameType,hiddenGameName,clientId,hiddenCurrencyCode,language,returnUrl); fetch(promotionGameUrl, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }) .then((response) => response.json()) .then((data) => { $("#game-frame").attr("src",data); $("#HiddenGameName").val(game); if (category == "Slots" || category == "Slots" + mobileString) { $("#HiddenGameType").val(hiddenGameType) }else{ $("#HiddenGameType").val(category); } $("#menu-popup").fadeOut(200) $(".show-menu-container").fadeOut(200) }) } $(document).ready(function () { $('.promotion-icon').on('click touchstart', function () { getPromotion(); }); getPromotions(); personalPromotionDiv() }); window.addEventListener('load', (event) => { if(gameCategory !== 'Slots') { //setTimeout(function() { if(hasPersonalOfferPromotion)showPersonalPromotion(); //}, 300); } }); window.addEventListener("message", function (event) { let message = event.data; if (message.name !== undefined) { if (message.name === 'loaded') { loaded = true; gameName = $('#HiddenGameName').val(); showPromotionButton(); getPromotions(); if(gameCategory === 'Slots') { if(hasPersonalOfferPromotion)showPersonalPromotion(); } $('#game-frame')[0].contentWindow.postMessage({ name: "help-gameinfo-data" }, "*"); $('.captionKey').each(function (e) { let attr = GetCaption($(this).data('caption')); $(this).html(attr); }); } else if (message.name === 'promotion-show') { getPromotion(); } else if (message.name === 'promotion-hide') { $('.promotion').css('display', 'none'); } else if (message.name === 'scale') { let scale = message.scale; $('.promotion-icon').css({ 'transform': 'scale(' + scale + ',' + scale + ')', top: 140 * scale }); if(bowser.mobile){ $('.XplusY-promotion-icon').css({ 'transform': 'scale(' + (scale - 0.17) + ',' + (scale - 0.17) + ')' }); $('.XplusY-promotion').css({ 'transform': 'scale(' + (scale - 0.17) + ',' + (scale - 0.17) + ')'}) }else{ $('.XplusY-promotion-icon').css({ 'transform': 'scale(' + scale + ',' + scale + ')', top: 120 * scale }); $('.XplusY-promotion').css({ 'transform': 'scale(' + scale + ',' + scale + ')'}) } } else if ( message.name === "autoplay-popup-true" ){ $(".XplusY-promotion-icon").css("visibility","hidden") } else if ( message.name === "autoplay-popup-false" ){ $(".XplusY-promotion-icon").css("visibility","visible") } else if (message.name === 'global-params') { globalParamsPromotion = event.data.globalParams; } } });